package com.ting.encrypt.config;

import com.ting.encrypt.encrypt.DefaultSM4Encrypt;
import com.ting.encrypt.interceptor.DecryptInterceptor;
import com.ting.encrypt.interceptor.EncryptInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class EncryptBeanConfig {

    @Bean
    public EncryptInterceptor encryptInterceptor() {
        return new EncryptInterceptor();
    }

    @Value("${rsa.public.key:MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCpLEl8flGQQUJBZIeatEVIyn794BSJEL7LWGUxIG4ct1hBs8314zq8lafE7JsVQNXyhC9MGxnJzQZdQ1ALzFJSEynablb3+j6SOhACWKDGwHroDPkBM9Fp3uqm1qn0GyHn8s0DSNAcEb731zyJnEix8qG6oXBHh4WUOCtio1moLwIDAQAB}")
    private String rsaPublicKey;

    @Value("${rsa.private.key:MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKksSXx+UZBBQkFkh5q0RUjKfv3gFIkQvstYZTEgbhy3WEGzzfXjOryVp8TsmxVA1fKEL0wbGcnNBl1DUAvMUlITKdpuVvf6PpI6EAJYoMbAeugM+QEz0Wne6qbWqfQbIefyzQNI0BwRvvfXPImcSLHyobqhcEeHhZQ4K2KjWagvAgMBAAECgYAd8N+kr/qhjFs8lZ1GbSdiBazKI/GefJ84ABIQysuSO4TcRAVswmWv4NDLkpC0B0CWZny0fIto4ueAdBxjqirbXz65WLozy0grHbDZ+qyMvhKhhVVP46txYHTTVRMfVFd6t2EdRGWBgjMN3pmq76DvqXy/R3CvHT3brPl6naA5sQJBAPPpmff+xNSZ08O2qGOjHqU+Imd5x3lpz+l1xdio+g82sO4zVtI3qJClBbr1cpZhQ9yJbFLB2oKWorVIMx+7LrkCQQCxjoCGKEAXioPYXdEmcKL+iXov3OlTChuxj+X12YFPBLpBJPiCGXUfOgkHE+r2i6cm+Fo4sxe3jbNzohBCbNonAkAiIstdndZGOtEcTu/6IdYkIjIGcVCteVWTwtvRmrSEdI8Gh0DbYtbAh5fptng2+53Xu5PhcSf3psVWwagGBNhhAkEAgV6qKJXVNRHYxOJ+jLqPGFUE8TDN1JJN4U9Op5YGEJQKPYL5ipmP6+O2RjDuBxtz/AICgsOC6VvWv876d9umCwJAV4T2zJ65V2oYZ8JWmZrOcSrFvNxE33a1lyaiEKNic7CWQfCwTO6tL7UNgkgdp9yYBVDCzwTLtlXKmhYANwQMEw==}")
    private String rsaPrivateKey;

    @Bean
    public DecryptInterceptor decryptInterceptor() {
        return new DecryptInterceptor();
    }

    @Bean
    public DefaultSM4Encrypt defaultSM4Encrypt(){
        return new DefaultSM4Encrypt(rsaPublicKey,rsaPrivateKey);
    }

}
